package cn.ren.service;

import cn.ren.dao.RpAddressDao;
import cn.ren.entity.PageResult;
import cn.ren.entity.QueryPageBean;
import cn.ren.pojo.RpAddress;
import com.alibaba.dubbo.config.annotation.Service;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @program: exercise_health
 * @description:
 * @author: ren
 * @create: 2020-03-10 17:19
 **/
@Service(interfaceClass = RpAddressService.class)
@Transactional
public class RpAddressServiceImpl implements RpAddressService {
    @Autowired
    private RpAddressDao rpAddressDao;

    @Override
    public PageResult findPage(QueryPageBean queryPageBean) {
        Integer currentPage = queryPageBean.getCurrentPage();
        Integer pageSize = queryPageBean.getPageSize();
        String queryString = queryPageBean.getQueryString();
        PageHelper.startPage(currentPage,pageSize);
        Page<RpAddress> list = rpAddressDao.findByCondition(queryString);
        return new PageResult(list.getTotal(),list.getResult());
    }

    @Override
    public List<RpAddress> findAll() {
        List<RpAddress> list = rpAddressDao.findAll();
        return list;
    }
}
